<?php
namespace app\service;
// +----------------------------------------------------------------------
// | bbcThink
// +----------------------------------------------------------------------
// | Copyright (c) 2025 http://bbcweb.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: bbcweb <22745529@qq.com>
// +----------------------------------------------------------------------
use think\facade\Db;

/**
 * 上传
 */
class UploadService
{
    public static function remove($param)
    {
        $param['name']=str_replace('http://m.bbcweb.cn','',$param['name']);
        if(empty($param['name']))
        {
            return ['code'=>0,'msg'=>'缺少参数'];
        }
        // if(strpos($param['name'],'http://')!=='false')
        // {
        //     $param['name']='/uploads'.explode('uploads',$param['name'])[1];
        // }
        if(file_exists($_SERVER["DOCUMENT_ROOT"].$param['name']))
        {
            unlink($_SERVER["DOCUMENT_ROOT"].$param['name']);
            Db::name('file')->where(['filepath'=>$param['name']])->delete();
        }
        return ['code'=>1,'msg'=>'删除成功'];
    }
}